package com.lb.base.enums;

import java.util.Arrays;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 楼盘照片类型(单选)
 *
 * @author libin
 * @since 2023-05-19
 **/
@Getter
@AllArgsConstructor
public enum BuildingPhotoTypeEnum {

    /**
     * 未知
     */
    UNKNOWN(-1, "未知"),

    /**
     * 楼盘外景照
     */
    EXTERIOR_VIEW_OF_THE_PROPERTY(1, "楼盘外景照"),

    /**
     * 等候厅照片
     */
    WAITING_HALL_PHOTOS(2, "等候厅照片"),

    /**
     * 客梯轿厢
     */
    PASSENGER_ELEVATOR_CAR(3, "客梯轿厢"),

    /**
     * 货梯轿厢
     */
    FREIGHT_ELEVATOR_CAR(4, "货梯轿厢"),
    ;

    /**
     * 编码
     */
    private final Integer code;

    /**
     * 名称
     */
    private final String name;

    /**
     * 根据code返回对应枚举对象
     **/
    public static BuildingPhotoTypeEnum parse(Integer code) {

        return Arrays.stream(BuildingPhotoTypeEnum.values())
                .filter(e -> code.equals(e.code)).findFirst()
                .orElse(UNKNOWN);
    }

    public static void main(String[] args) {

        BuildingPhotoTypeEnum parse = parse(null);
        System.out.println(parse.getName());
    }
}